package com.swfgui.controls
{
	import Common.base.config.SoundConfig;
	
	import GameMain.utility.CursorUtil;
	
	import com.swfgui.managers.SoundManager;
	
	import flash.events.MouseEvent;
	
	public class LinkButton extends Label
	{
		public function LinkButton(viewSource:Object=null)
		{
			super(viewSource);
		}
		
		override public function dispose():void
		{
			if(hasDisposed)
			{
				return;
			}
			
			this.removeEventListener(MouseEvent.ROLL_OVER, onMouseOver);
			this.removeEventListener(MouseEvent.ROLL_OUT, onMouseOut);
			this.removeEventListener(MouseEvent.CLICK, onMouseClk);
			
			super.dispose();
		}
		
		override protected function initialize():void
		{
			super.initialize();
			
			defaultTextFormat.underline = true;
			viewText.setTextFormat(defaultTextFormat);
			viewText.defaultTextFormat = defaultTextFormat;
			
			setHandCursor(Button.BUTTON_USE_HAND_CURSOR);
			
			this.addEventListener(MouseEvent.ROLL_OVER, onMouseOver);
			this.addEventListener(MouseEvent.ROLL_OUT, onMouseOut);
			this.addEventListener(MouseEvent.CLICK, onMouseClk);
		}
		
		protected function onMouseClk(event:MouseEvent):void
		{
			SoundManager.instance.playEffectSound(SoundConfig.instance.getSoundById(18));
		}
		
		protected function onMouseOver(event:MouseEvent):void
		{
			CursorUtil.setHandCursor();
		}
		
		protected function onMouseOut(event:MouseEvent):void
		{
			CursorUtil.setNormalCursor();
		}
	}
}